"""配置模块"""

# 为了避免循环导入，这里不导入config.py中的函数
# 其他模块应该直接从src.config导入get_settings等函数

from .ai_config import AIDetectionConfig
from .medical_knowledge import MedicalKnowledgeBase, BASPType
from .settings import get_settings, Settings

# TORTOISE_ORM配置供aerich使用
import os
from typing import Optional

def _get_env_file() -> str:
    """获取环境配置文件路径"""
    env = os.getenv("ENV", "develop")
    if env == "product":
        return ".env.product"
    return ".env.develop"

# 加载环境变量
from dotenv import load_dotenv
load_dotenv(_get_env_file())

# 数据库配置
MYSQL_HOST = os.getenv("MYSQL_HOST", "localhost")
MYSQL_PORT = int(os.getenv("MYSQL_PORT", "3306"))
MYSQL_USER = os.getenv("MYSQL_USER", "root")
MYSQL_PASS = os.getenv("MYSQL_PASS", "123456")
MYSQL_DB = os.getenv("MYSQL_DB", "ewentianshi_dev")

TORTOISE_ORM = {
    "connections": {
        "default": f"mysql://{MYSQL_USER}:{MYSQL_PASS}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}"
    },
    "apps": {
        "models": {
            "models": ["src.models", "aerich.models"],
            "default_connection": "default",
        }
    },
    "use_tz": False,
    "timezone": "Asia/Shanghai",
}

__all__ = ['AIDetectionConfig', 'MedicalKnowledgeBase', 'BASPType', 'TORTOISE_ORM', 'get_settings', 'Settings']